package pzl.com.library.chart;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import java.util.ArrayList;

import pzl.com.library.data.BaseData;
import pzl.com.library.data.Entry;
import pzl.com.library.data.LineData;
import pzl.com.library.listener.ChartTouchListener;
import pzl.com.library.listener.LineTouchListener;
import pzl.com.library.renderer.BaseAxisRenderer;
import pzl.com.library.renderer.BaseDataRenderer;
import pzl.com.library.renderer.LineDataRenderer;

/**
 * @author zl.peng
 * @version [1.0, 2016-11-21]
 */
public class LineChart extends LinearChart {
    public static final String TAG = "LineChart";


    public LineChart(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public LineChart(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public LineChart(Context context) {
        super(context);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int w = MeasureSpec.getSize(widthMeasureSpec);
        int h = MeasureSpec.getSize(heightMeasureSpec);
        setMeasuredDimension(w, h);
    }

    @Override
    public void init() {
        Log.d(TAG, "LineChart init");
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        super.init();
    }

    @Override
    ChartTouchListener onCreateChartTouchListener() {
        return new LineTouchListener(this);
    }

    @Override
    BaseData onCreateBaseData() {
        return new LineData(this);
    }

    @Override
    BaseDataRenderer onCreateBaseRenderer() {
        return new LineDataRenderer();
    }


    public void addEntry(String key, Entry e) {
        mBaseData.addEntry(key, e);
    }


}
